package com.oocl.im.action.impl;

import com.oocl.im.action.IAction;
import com.oocl.im.entity.Client;
import com.oocl.im.entity.Protocol;

import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;

import com.oocl.im.outputstream.NetOutput;
import com.oocl.im.constants.ClientMaintenance;
import com.oocl.im.constants.Constants;
import com.oocl.im.handle.IHandle;

public class ChatAction implements IAction {
	
	ObjectOutputStream oos;
	String content;
	
	public ChatAction(String content) {
		super();
		this.content = content;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public ChatAction(ObjectOutputStream oos) {
		super();
		this.oos = oos;
	}

	public void execute(Protocol protocol) {

		Client to=ClientMaintenance.currentChatUser;
		Map<String,Object> params = new HashMap<String, Object>();
		params.put(Constants.FROM, ClientMaintenance.client.getAccount());
		params.put(Constants.TO, to);
		params.put(Constants.CONTENT, content);
		protocol = new Protocol(Constants.CHAT, params);

		NetOutput netOutput = new NetOutput(oos);
		netOutput.write(protocol);
		
	}

	

}
